package com.briup.estore.web.servlet;

import com.briup.estore.common.result.Result;
import com.briup.estore.service.CollectService;
import com.briup.estore.service.impl.CollectServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author briup-adam
 * @Date 2023/8/4 上午10:03
 * @Description 用户选择书籍新建收藏
 **/
@WebServlet("/collect/add")
public class CollectAddServlet extends BaseServlet {
    private CollectService collectService = new CollectServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String bookId = req.getParameter("id");
        String userId = (String) req.getAttribute("userId");
        collectService.addCollect(Integer.parseInt(userId), Integer.valueOf(bookId));
        writeData(resp, Result.success());
    }
}
